from odoo import api, fields, models


class Instrument(models.Model):
    _name = "instrument.base"
    _description = "the basic information of the instruments"
    instrument_id = fields.Char(
        string='器具编号',
        index=True,
        readonly=True,
    )

    @api.model
    def create(self, vals):
        vals['instrument_id'] = self.env['ir.sequence'].next_by_code('instrument.base') or ''
        return super(Instrument, self).create(vals)

    name = fields.Char(
        string='产品名称',
        required=True
    )
    produce_company = fields.Many2one(
        'res.company',
        string='生产企业',
        required=True
    )
    produce_number = fields.Char(
        string='生产批号',
        required=True
    )
    register_number = fields.Char(
        string='注册号',
        required=True
    )
